# Maintainer: Clayton Craft <clayton@craftyguy.net>
# Co-Maintainer: jane400 <jane400@postmarketos.org>
# Contributor: Konrad Dybcio <konradybcio@kernel.org>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-lenovo-21bx
pkgdesc="Lenovo ThinkPad X13s"
pkgver=12
pkgrel=1
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck !strip"
depends="
	alsa-ucm-conf
	bootmac
	firmware-lenovo-21bx
	libmbim-tools
	linux-firmware-ath11k
	linux-firmware-qca
	linux-firmware-qcom
	linux-postmarketos-qcom-laptop
	postmarketos-base
	qmi-utils
	systemd-boot
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	firmware.files
	modules-initfs
	pipewire.conf
	usbguard.conf
"
subpackages="
	$pkgname-usbguard
	$pkgname-vulkan
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -Dm644 "$srcdir/"/firmware.files \
		-t "$pkgdir"/usr/share/mkinitfs/files/
	install -Dm644 "$srcdir"/pipewire.conf \
		-t "pkgdir"/usr/share/pipewire/pipewire.conf.d/
}

vulkan() {
	install_if="$pkgname=$pkgver-r$pkgrel vulkan-loader"
	depends="mesa-vulkan-freedreno"
	mkdir "$subpkgdir"
}

usbguard() {
	install_if="$pkgname=$pkgver-r$pkgrel usbguard"
	install -Dm600 "$srcdir"/usbguard.conf \
		"$subpkgdir"/etc/usbguard/rules.d/"$pkgname".conf
	devicepkg_package $startdir $pkgname
}

sha512sums="
9cb08de5748b0339005a910cc0475ad344dc6e912e477c5bd6b370784af6309719524f8fa7a39e7565586e47968a35c344ea853cddd716cc3e1e483efaae7ff0  deviceinfo
5f4e6a80455c8a2ed879bfd457a89f81790824657ed4101e03b7ec288a274e63340f48e2ad5028cf83744263a4529584b1e94c36d10b98912e5b31804fa98ff0  firmware.files
27705e998db262602b50004083fe160dbcde88e9fdcaeb43e3d1d79be0b7af371f84855bb93ba16ada3cf5fa8ff8da6ca159cda4b1de08fb54ac451c57169c57  modules-initfs
52bbb9564ec713db5d46937701b121afe0c6c644fffe189a05766f491b4997b1bbc4c1f90229efb5764d795df8d40a57d4c840ee4b32d426e7a84520364b8bf5  pipewire.conf
0d0412eb1f01af39000c39391f622640461305d83dae1a53aa7eef640cc17fd265cabca4e4e57dea053c47a4e50f9feb90f12ee5310d5b6425783e83efc5f9d8  usbguard.conf
"
